gh-107557: Setup abstract interpretation#107847
Merged
Fidget-Spinner merged 54 commits intopython:mainfrom Aug 15, 2023
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is joint work by @JuliaPoo and me, supported by the NUS TEST Lab.
This implements a subset of partial evaluation (specifically, constant propagation), using a technique described for our type propagation in our Tier 2 interpreter report and abstract interpretation over uops.The main goal of upstreaming this PR is to set up the infrastructure for optimization passes of CPython uops. With constant propagation, turning global loads or attribute loads to constants at the region formation phase will open up further optimizations in subsequent passes. This PR also makes CPython uops ready for type propagation, thus allowing wide-scale typed operations.
Features:
Partitioning of values on the stack and locals into static/dynamic using the concept of "partitions of nodes".Introduces the concept of "pure" operations, and what can be ascertained about them.Constant propagation purely via abstract interpretation of bytecode, with no requirement for SSA or AST.An optimization pass to remove redundantSAVE_IPs after partial evaluation.Jump target/instruction numbering, which allows us to freely relocate jump targets/instructions, as a final pass will fix them up.Example:
We have the following test case.
This is now essentially simplified down to:
Which roughly halves the trace length.
TODO:
lltraceconvention commonly seen in rest of the uops codebase.